object HundredDollarDrink {


  def getBottle(empty:Int,lib:Int,beers:Int): Int ={


    var newBeers = empty/3+lib/5
    var newEmpty =  empty%3
    var newLib = lib%5
    if (newEmpty+newBeers<3 && newLib+newBeers<5){
       return beers+newBeers
    }

    return beers+getBottle(newEmpty+newBeers,newLib+newBeers,newBeers)
  }

  def main(args: Array[String]): Unit = {
    var initial : Int = 100/2
    println(getBottle(initial,initial,initial))
  }
}
